package l2ft.gameserver.network.l2.s2c;

import l2ft.gameserver.model.items.ItemInstance;
import l2ft.gameserver.model.mail.Mail;
import l2ft.gameserver.network.l2.c2s.RequestExCancelSentPost;
import l2ft.gameserver.network.l2.c2s.RequestExRequestSentPost;

/**
 * ???????? ???????????? ????????????? ??????. Ш????? ? ????? ?? {@link RequestExRequestSentPost}.
 * ??? ??????? ?? ?????? Cancel ?????? ???? {@link RequestExCancelSentPost}.
 * @see ExReplyReceivedPost
 */
public class ExReplySentPost extends L2GameServerPacket
{
	private final Mail mail;

	public ExReplySentPost(Mail mail)
	{
		this.mail = mail;
	}

	// ddSSS dx[hddQdddhhhhhhhhhh] Qd
	@Override
	protected void writeImpl()
	{
		writeEx(0xAD);

		writeD(mail.getMessageId()); // id ??????
		writeD(mail.isPayOnDelivery() ? 1 : 0); // 1 - ?????? ? ???????? ??????, 0 - ?????? ??????

		writeS(mail.getReceiverName()); // ????
		writeS(mail.getTopic()); // ?????
		writeS(mail.getBody()); // ????

		writeD(mail.getAttachments().size()); // ?????????? ??????????? ?????
		for(ItemInstance item : mail.getAttachments())
		{
			writeItemInfo(item);		
			writeD(item.getObjectId());
		}

		writeQ(mail.getPrice()); // ??? ????? ? ??????? - ????
		writeD(0); // ?
	}
}